home *** CD-ROM | disk | FTP | other *** search
- property _me, pTable, pSuperTable, pTableChannel, pTableLoc, pVSlider, pHSlider, pVisRect, pMinRect, pL, pT, pSpriteWidth, pSpriteHeight, pMemWidth, pMemHeight, pStageRect, pStdRowHeight, pColWidthList, pNewSpriteRect
- global gGraph
-
- on new me, tableName, castName, tableChannel, tableLoc, vSlider, HSlider, descendant
- if objectp(descendant) then
- _me = descendant
- else
- _me = me
- end if
- pTable = member(tableName, castName)
- pTableChannel = tableChannel
- puppetSprite(pTableChannel, 1)
- set the member of sprite pTableChannel to pTable
- pTableLoc = tableLoc
- pVSlider = vSlider
- pHSlider = HSlider
- pStdRowHeight = getRowHeight(member(pTable), 1)
- pColWidthList = GetWidthList(me)
- return me
- end
-
- on init me, Var
- pStageRect = rect(0, 0, the stageRight - the stageLeft, the stageBottom - the stageTop)
- pMinRect = Var
- set the rect of sprite the pTableChannel of me to pMinRect
- pL = getAt(pMinRect, 1)
- pT = getAt(pMinRect, 2)
- if IsTableVisible(me) then
- set the loc of sprite the pTableChannel of me to CalcCenterofRect(_me, pMinRect)
- pSpriteWidth = the width of sprite pTableChannel
- pSpriteHeight = the height of sprite pTableChannel
- pMemWidth = member(pTable).width
- pMemHeight = member(pTable).height
- end if
- return me
- end
-
- on setSuperTable me, superTable
- pSuperTable = superTable
- return me
- end
-
- on MapCharsToPlatform me
- if the machineType = 256 then
- dataList = member(pTable).tableData
- FindText = numToChar(202)
- ReplaceText = numToChar(160)
- MaxCount = count(dataList)
- repeat with rc = 1 to MaxCount
- xText = getAt(dataList, rc)
- nbsCount = CountNBSpace(xText)
- TestInteger = MakeNumericOnly(xText)
- if integer(TestInteger) > 10000 then
- nothing()
- end if
- xText = FindandReplace(xText, FindText, ReplaceText)
- xText = CharMaptoPC(xText)
- case nbsCount of
- 1:
- xText = AppendNbs(xText, 2)
- 2:
- xText = AppendNbs(xText, 3)
- 3:
- xText = AppendNbs(xText, 5)
- 4:
- xText = AppendNbs(xText, 5)
- 5:
- xText = AppendNbs(xText, 7)
- 6:
- xText = AppendNbs(xText, 7)
- 7:
- xText = AppendNbs(xText, 7)
- 8:
- xText = AppendNbs(xText, 8)
- 9:
- xText = AppendNbs(xText, 8)
- 10:
- xText = AppendNbs(xText, 9)
- end case
- setAt(dataList, rc, xText)
- end repeat
- member(pTable).tableData = dataList
- end if
- return me
- end
-
- on SetPostShowProps me
- SpriteRect = the rect of sprite pTableChannel
- SouthEastCell = getMouseCell(_me, getAt(SpriteRect, 3) - 2, getAt(SpriteRect, 4) - 2)
- pVisRect = rect(point(1, 1), SouthEastCell)
- return me
- end
-
- on GetInvisibleRowCount me
- RealRowHeight = pStdRowHeight - 1
- MaxRow = getNumRows(me)
- Settings = MaxRow - getAt(pVisRect, 4) + 1
- repeat with rc = 1 to MaxRow
- RowHeight = getRowHeight(member(pTable), rc)
- if RowHeight > pStdRowHeight then
- AddToSetting = (RowHeight / RealRowHeight) - 1
- Settings = Settings + AddToSetting
- end if
- end repeat
- return Settings
- end
-
- on GetInvisibleColumnCount me
- xMax = pSpriteWidth + 1
- CummWidth = 0
- MaxColumnCount = getNumColumns(me)
- VisibleColumns = 0
- if MaxColumnCount = 1 then
- VisibleColumns = 2
- else
- PrevWidth = 0
- repeat with rc = 1 to MaxColumnCount
- CurrWidth = getColumnWidth(member(pTable), rc) - 1
- if (PrevWidth + 10) > (CurrWidth * 2) then
- VisibleColumns = VisibleColumns + 1
- end if
- if (CummWidth + CurrWidth) < xMax then
- CummWidth = CummWidth + CurrWidth
- VisibleColumns = VisibleColumns + 1
- else
- exit repeat
- end if
- PrevWidth = CurrWidth
- end repeat
- end if
- return MaxColumnCount - VisibleColumns + 1
- end
-
- on condemn me
- _me = 0
- return me
- end
-
- on Inscope me
- puppetSprite(pTableChannel, 1)
- return me
- end
-
- on outScope me
- puppetSprite(pTableChannel, 0)
- return me
- end
-
- on showMe me
- set the loc of sprite pTableChannel to pTableLoc
- updateStage()
- return me
- end
-
- on hideMe me
- set the loc of sprite pTableChannel to point(-9999, -9999)
- updateStage()
- return me
- end
-
- on trackMouse me
- return me
- end
-
- on doRollover me
- return me
- end
-
- on scrollToTop me
- if IsTableVisible() then
- sprite(pTableChannel).vScroll = 0
- end if
- return me
- end
-
- on scrollToLeft me
- if IsTableVisible() then
- sprite(pTableChannel).hScroll = 0
- end if
- return me
- end
-
- on scrollUp me
- if IsTableVisible() then
- oldTop = pVisRect.top
- pVisRect.top = pVisRect.top + (getSetting(pVSlider) - oldTop)
- pVisRect.bottom = pVisRect.bottom + (getSetting(pVSlider) - oldTop)
- sprite(pTableChannel).vScroll = (pStdRowHeight - 1) * (getSetting(pVSlider) - 1)
- end if
- return me
- end
-
- on scrollDown me
- if IsTableVisible() then
- oldTop = pVisRect.top
- pVisRect.top = pVisRect.top + (getSetting(pVSlider) - oldTop)
- pVisRect.bottom = pVisRect.bottom + (getSetting(pVSlider) - oldTop)
- sprite(pTableChannel).vScroll = (pStdRowHeight - 1) * (getSetting(pVSlider) - 1)
- end if
- return me
- end
-
- on scrollLeft me, HScrollIncrement
- if IsTableVisible() then
- oldLeft = pVisRect.left
- pVisRect.left = pVisRect.left + (getSetting(pHSlider) - oldLeft)
- increment = CountVisibleColumns(me)
- pVisRect.right = pVisRect.left + increment
- if voidp(HScrollIncrement) then
- sprite(pTableChannel).hScroll = (getColumnWidth(member(pTable), oldLeft) - 1) * (getSetting(pHSlider) - 1)
- else
- sprite(pTableChannel).hScroll = HScrollIncrement
- end if
- end if
- return me
- end
-
- on scrollRight me, HScrollIncrement
- if IsTableVisible() then
- if voidp(HScrollIncrement) then
- oldLeft = pVisRect.left
- pVisRect.left = pVisRect.left + (getSetting(pHSlider) - oldLeft)
- increment = CountVisibleColumns(me)
- pVisRect.right = pVisRect.left + increment
- sprite(pTableChannel).hScroll = (getColumnWidth(member(pTable), oldLeft) - 1) * (getSetting(pHSlider) - 1)
- else
- if maxReached(pHSlider) then
- pVisRect.left = CountColumnsMaxReached(me)
- pVisRect.right = getNumColumns(me)
- else
- Adder = CountColumnsInWidth(me, HScrollIncrement)
- pVisRect.left = pVisRect.left + Adder
- pVisRect.right = pVisRect.right + Adder
- end if
- sprite(pTableChannel).hScroll = HScrollIncrement
- end if
- end if
- return me
- end
-
- on CountVisibleColumns me
- CummWidth = 0
- MaxCount = count(pColWidthList)
- setting = pVisRect.left
- columnCount = 0
- repeat with rc = setting to MaxCount
- Test = CummWidth + getAt(pColWidthList, rc)
- if Test < pSpriteWidth then
- CummWidth = Test
- columnCount = columnCount + 1
- end if
- end repeat
- if columnCount = 1 then
- columnCount = 0
- end if
- return columnCount
- end
-
- on CountColumnsMaxReached me
- CummWidth = 0
- MaxCount = count(pColWidthList)
- repeat with rc = MaxCount down to 1
- Test = CummWidth + getAt(pColWidthList, rc)
- if Test < pSpriteWidth then
- CummWidth = Test
- next repeat
- end if
- exit repeat
- end repeat
- return rc
- end
-
- on CountColumnsInWidth me, width
- start = pVisRect.left
- MaxCount = count(pColWidthList)
- CummWidth = 0
- repeat with rc = start to MaxCount
- Test = CummWidth + getAt(pColWidthList, rc)
- if Test < width then
- CummWidth = Test
- next repeat
- end if
- if rc = 1 then
- ReturnVar = rc
- else
- ReturnVar = rc - start
- end if
- exit repeat
- end repeat
- if voidp(ReturnVar) then
- ReturnVar = rc - start - 1
- end if
- return ReturnVar
- end
-
- on JustifyText me, WhichSide
- member(pTable).defaultHAlign = WhichSide
- end
-
- on getTopRow me
- return pVisRect.top
- end
-
- on getLeftColumn me
- return pVisRect.left
- end
-
- on atTop me
- return pVisRect.top = 1
- end
-
- on atBottom me
- return pVisRect.bottom = pTable.rowCount
- end
-
- on atLeft me
- return pVisRect.left = 1
- end
-
- on atRight me
- return pVisRect.right = pTable.columnCount
- end
-
- on isLeftOf me, h
- return h <= the left of sprite pTableChannel
- end
-
- on isRightOf me, h
- return h > the right of sprite pTableChannel
- end
-
- on getMouseCell me, h, v
- if v <= the top of sprite pTableChannel then
- v = the top of sprite pTableChannel + 1
- else
- if v > the bottom of sprite pTableChannel then
- v = the bottom of sprite pTableChannel - 1
- end if
- end if
- if h <= the left of sprite pTableChannel then
- h = the left of sprite pTableChannel + 1
- else
- if h > the right of sprite pTableChannel then
- h = the right of sprite pTableChannel - 1
- end if
- end if
- return cellToPoint(me._me, pointToCell(sprite(pTableChannel), point(h, v)))
- end
-
- on getVisRect me, theRect
- R = rect(0, 0, 0, 0)
- if not ((theRect.left > pVisRect.right) or (theRect.top > pVisRect.bottom) or (theRect.right < pVisRect.left) or (theRect.bottom < pVisRect.top)) then
- R.left = max(theRect.left, pVisRect.left)
- R.top = max(theRect.top, pVisRect.top)
- R.right = min(theRect.right, pVisRect.right)
- R.bottom = min(theRect.bottom, pVisRect.bottom)
- end if
- if R <> rect(0, 0, 0, 0) then
- r1 = getCellRect(sprite(pTableChannel), point(getAt(R, 1), getAt(R, 2)))
- r2 = getCellRect(sprite(pTableChannel), point(getAt(R, 3), getAt(R, 4)))
- if voidp(r1) or voidp(r2) then
- R = rect(0, 0, 0, 0)
- else
- R = rect(r1.left, r1.top, r2.right, r2.bottom)
- end if
- end if
- return R
- end
-
- on cellToPoint me, theCell
- if (theCell mod pTable.columnCount) = 0 then
- return point(pTable.columnCount, theCell / pTable.columnCount)
- else
- return point(theCell mod pTable.columnCount, (theCell / pTable.columnCount) + 1)
- end if
- end
-
- on getCellRect me, theCell
- return getCellRect(sprite(pTableChannel), theCell)
- end
-
- on isCellVisible me, theCellRect
- return intersect(the rect of sprite pTableChannel, theCellRect) <> rect(0, 0, 0, 0)
- end
-
- on GetMaxVisibleXPixel me, xMax
- CummWidth = pL + 1
- MaxColumnCount = getNumColumns(me)
- if MaxColumnCount = 1 then
- CummWidth = CummWidth + getColumnWidth(member(pTable), 1)
- else
- repeat with rc = 1 to MaxColumnCount
- CurrWidth = getColumnWidth(member(pTable), rc) - 1
- if (CummWidth + CurrWidth) < xMax then
- CummWidth = CummWidth + CurrWidth
- next repeat
- end if
- exit repeat
- end repeat
- end if
- return CummWidth
- end
-
- on GetMaxVisibleYPixel me, yMax
- CummHeight = pT
- MaxRowCount = getNumRows(me)
- repeat with rc = 1 to MaxRowCount
- CurrHeight = getRowHeight(member(pTable), rc) - 1
- if (CummHeight + CurrHeight) < yMax then
- CummHeight = CummHeight + CurrHeight
- next repeat
- end if
- exit repeat
- end repeat
- return CummHeight
- end
-
- on SetTableMin me
- if IsTableVisible() then
- pNewSpriteRect = pMinRect
- set the rect of sprite pTableChannel to pMinRect
- set the loc of sprite pTableChannel to CalcCenterofRect(_me, pNewSpriteRect)
- pSpriteWidth = the width of sprite pTableChannel
- pSpriteHeight = the height of sprite pTableChannel
- end if
- end
-
- on SetTableMax me, xMax, yMax
- if IsTableVisible() then
- if not voidp(xMax) then
- SetWidth(me, xMax)
- pSpriteWidth = the width of sprite pTableChannel
- end if
- if not voidp(yMax) then
- SetHeight(me, yMax)
- pSpriteHeight = the height of sprite pTableChannel
- end if
- pNewSpriteRect = rect(pL, pT, pL + the width of sprite pTableChannel, pT + the height of sprite pTableChannel)
- if not voidp(xMax) or not voidp(yMax) then
- set the loc of sprite pTableChannel to CalcCenterofRect(_me, pNewSpriteRect)
- end if
- end if
- end
-
- on SetWidth me, xMax
- if (pL + pMemWidth) < xMax then
- set the width of sprite pTableChannel to pMemWidth
- else
- set the width of sprite pTableChannel to xMax - pL
- end if
- end
-
- on SetHeight me, yMax
- if (pT + pMemHeight) < yMax then
- set the height of sprite pTableChannel to pMemHeight
- else
- set the height of sprite pTableChannel to yMax - pT
- end if
- end
-
- on getSelectedData me, theRect
- offset = 17
- fMember = the number of member pTable + offset
- data = value(the text of field fMember)
- selectedData = []
- repeat with i = theRect.top to theRect.bottom
- repeat with j = theRect.left to theRect.right
- append(selectedData, getAt(data, ((i - 1) * pTable.columnCount) + j))
- end repeat
- end repeat
- MaxCount = count(selectedData)
- repeat with rc = 1 to MaxCount
- xText = getAt(selectedData, rc)
- xText = FindandReplace(xText, RETURN, " ")
- xText = RemoveBorderSpaces(xText)
- setAt(selectedData, rc, xText)
- end repeat
- return selectedData
- end
-
- on GetNewRect me
- return rect(pL, pT, pL + the width of sprite pTableChannel, pT + the height of sprite pTableChannel)
- end
-
- on GetWidthList me
- xList = []
- MaxCol = getNumColumns(me)
- repeat with xCol = 1 to MaxCol
- append(xList, getColumnWidth(pTable, xCol) - 1)
- end repeat
- return xList
- end
-
- on getNumColumns me
- return pTable.columnCount
- end
-
- on getNumRows me
- return pTable.rowCount
- end
-
- on isAbove me, v
- return v <= the top of sprite pTableChannel
- end
-
- on isBelow me, v
- return v > the bottom of sprite pTableChannel
- end
-
- on IsTableVisible me
- return inside(point(pL, pT), pStageRect)
- end
-
- on buttonLoc me
- return me
- end
-